﻿using Data.Model.SqlServer;
using DataService.Core.Extensions;
using DataService.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;


namespace UnitTest
{
    public class TestExpression
    {
        public void Test()
        {
            Expression<Func<TB_PersonnelInformation, bool>> expression = t => !t.IsDelete;

            Guid[] ttt = new Guid[] { Guid.Parse("13F4035D-F2B1-481E-8D2A-2BB99682EB05"), Guid.Parse("CFEE30B3-5207-4888-A810-B4E27E80C2C8") };
            Guid[] ttt11 = new Guid[] { Guid.Parse("1D319D7E-F259-4BA1-BDAC-A306E9CCD069"), Guid.Parse("74119852-8386-41BC-96CF-8EB99E1A60F0") };
            Guid[] ttt22 = new Guid[] { Guid.Parse("2D319D7E-F259-4BA1-BDAC-A306E9CCD069"), Guid.Parse("24119852-8386-41BC-96CF-8EB99E1A60F0") };
            Guid[] ttt33 = new Guid[] { Guid.Parse("3D319D7E-F259-4BA1-BDAC-A306E9CCD069"), Guid.Parse("34119852-8386-41BC-96CF-8EB99E1A60F0") };
            Expression<Func<TB_PersonnelInformation, bool>> expression111 = x => ttt.Contains(x.ID);
            expression111 = expression111.MergeOr(t => ttt11.Contains(t.ID));
            expression111 = expression111.MergeOr(t => ttt22.Contains(t.ID));
            expression111 = expression111.MergeOr(t => ttt33.Contains(t.ID));

            expression = expression.And(expression111);


            ResolveExpress resolve = new ResolveExpress();
            var dic = resolve.ResolveExpression<TB_PersonnelInformation>(expression,"@");
            Console.WriteLine(dic["sql"]);
            foreach (var item in dic["values"] as Dictionary<string, object>)
            {
                Console.WriteLine(item.Key + "***" + item.Value);
            }

            //expression 生成  ((IsDelete = @IsDelete) and (((ID in (@ID0,@ID1) or ID in (@ID01,@ID12)) or ID in (@ID03,@ID14)) or ID in (@ID05,@ID16)))
        }
    }
}
